package com.tyk.bookstore.front.product.repository;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tyk.bookstore.front.common.core.model.vo.SuggestionVo;
import com.tyk.bookstore.front.common.dal.mapper.IMapper;
import com.tyk.bookstore.front.product.model.dto.*;
import com.tyk.bookstore.front.product.model.entity.BookDo;
import com.tyk.bookstore.front.product.model.query.Book4OrderPriceCheckQuery;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Set;

/**
 * @author tyk
 * @description 书籍管理
 */
@Mapper
public interface BookRepository extends IMapper<BookDo> {

    BookDto selectBookDtoById(@Param("id") Long id);

    String selectNameById(@Param("id") Long id);

    List<Long> selectIdListByNameLike(@Param("id") String name);

    Book4CartDto selectBook4CartDtoById(@Param("id") Long id);


    /**
     * 获取创建订单所需商品信息
     */
    List<Book4OrderDto> selectBook4OrderDtoListByIdSet(@Param("idSet") Set<Long> idSet);

    /**
     * 统计符合条件的数据的数目
     */
    Long countByIdAndPrice(@Param("queryList") List<Book4OrderPriceCheckQuery> queryList);

    Long existById(@Param("id") Long id);

    List<BookDo> selectListByWrapper(@Param("ew") LambdaQueryWrapper<BookDo> ew);

    List<Long> selectIdListByWrapper(@Param("ew") LambdaQueryWrapper<BookDo> ew);


    List<BookCardDto> selectListByIdList(@Param("idSet") Set<Long> idSet);

    List<SuggestionVo> selectSuggestionList(@Param("nameLike") String nameLike);

    /**
     * 查询书籍信息
     */
    List<Book4CartDto> selectBook4CartDtoListByIdSet(@Param("idSet") Set<Long> idSet, @Param("limit") int limit);

    /**
     * 查询书籍信息
     */
    List<Book4OrderCommentSuggestionDto> selectBook4OrderCommentSuggestionDtoListByIdSet(Set<Long> idSet);
}
